<template>
  <div class="progress-timeline">
    <div 
      v-for="(item, index) in progressList" 
      :key="index"
      class="timeline-item"
      :class="{ 
        'active': item.nodeStatus === 'PROCESSING',
        'completed': item.nodeStatus === 'COMPLETED'
      }"
    >
      <div class="timeline-dot">
        <van-icon 
          v-if="item.nodeStatus === 'COMPLETED'" 
          name="success" 
          color="#07c160" 
        />
        <van-icon 
          v-else-if="item.nodeStatus === 'PROCESSING'" 
          name="clock-o" 
          color="#1989fa" 
        />
        <div v-else class="dot-empty"></div>
      </div>
      
      <div class="timeline-content">
        <div class="timeline-title">
          {{ item.nodeName }}
        </div>
        <div v-if="item.nodeTime" class="timeline-time">
          <van-icon name="clock-o" />
          {{ item.nodeTime }}
        </div>
        <div v-if="item.remark" class="timeline-remark">
          {{ item.remark }}
        </div>
        <div v-if="item.operatorName" class="timeline-operator">
          {{ item.operatorName }}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from 'vue'

const props = defineProps({
  progressList: {
    type: Array,
    required: true,
    default: () => []
  }
})
</script>

<style scoped lang="scss">
.progress-timeline {
  padding: 0;
}

.timeline-item {
  display: flex;
  position: relative;
  padding-bottom: 28px;
  animation: fadeIn 0.5s ease-out;
  
  &:last-child {
    padding-bottom: 0;
    
    .timeline-dot::after {
      display: none;
    }
  }
  
  &.completed {
    .timeline-title {
      color: #323233;
      font-weight: 600;
    }
    
    .timeline-dot {
      animation: scaleIn 0.5s ease-out;
    }
  }
  
  &.active {
    .timeline-title {
      color: #1989fa;
      font-weight: 600;
    }
    
    .timeline-content {
      background: linear-gradient(135deg, #f0f9ff 0%, #e6f7ff 100%);
      border-radius: 12px;
      padding: 14px;
      margin-left: -14px;
      margin-right: -14px;
      padding-left: 28px;
      box-shadow: 0 2px 8px rgba(25, 137, 250, 0.15);
    }
    
    .timeline-dot {
      animation: pulse 2s ease-in-out infinite;
    }
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.timeline-dot {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  background: #fff;
  border-radius: 50%;
  
  .van-icon {
    font-size: 22px;
  }
  
  .dot-empty {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #dcdee0;
    border: 2px solid #fff;
  }
  
  &::after {
    content: '';
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: calc(100% + 28px);
    background: #ebedf0;
    z-index: 1;
    border-radius: 2px;
  }
}

.timeline-item.completed .timeline-dot::after {
  background: linear-gradient(180deg, #07c160 0%, #c8f7dc 100%);
}

.timeline-item.active .timeline-dot::after {
  background: linear-gradient(180deg, #1989fa 0%, #b3e0ff 100%);
}

.timeline-content {
  flex: 1;
  margin-left: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-title {
  font-size: 15px;
  color: #646566;
  margin-bottom: 6px;
  transition: all 0.3s;
  line-height: 1.4;
}

.timeline-time {
  font-size: 12px;
  color: #969799;
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  
  .van-icon {
    font-size: 12px;
    margin-right: 4px;
  }
}

.timeline-remark {
  font-size: 13px;
  color: #646566;
  margin-top: 6px;
  line-height: 1.6;
  padding: 8px 12px;
  background: #f7f8fa;
  border-radius: 8px;
}

.timeline-operator {
  font-size: 12px;
  color: #969799;
  margin-top: 6px;
  font-style: italic;
}
</style>

